package com.seventh.parkingrent.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.seventh.parkingrent.domain.CarInfo;
import com.seventh.parkingrent.dao.CarInfoMapper;
import com.seventh.parkingrent.service.ICarInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Lucas
 * @since 2021-08-24
 */
@Service
@Slf4j
public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> implements ICarInfoService {
    @Autowired
    private CarInfoMapper carInfoMapper;

    //根据用户id获取用户已有车辆
    @Override
    public List<CarInfo> getCarsById(Integer id) {
        log.info("车辆服务实现层根据用户id获取车辆信息，id为{}",id);
        QueryWrapper<CarInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",id);
        return carInfoMapper.selectList(wrapper);
    }
}
